﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

namespace Pc_Vision.DAOFactorys
{
    public class DAOproduct : DbConnection
    {
        public void InsertProduct(Model.Product p)
        {
            string query = "INSERT INTO product (Artikelnummer, Productnaam, Inkoopprijs, Verkoopprijs, Opvoorraad, Productomschrijving, Systeemtype, Processor,"
                + " Geheugen, Opslag, Optischeschijf, Display, Videokaart, Netwerkkaart, Batterij, Afmetingen, Gewicht, Garantie, Actieprijs, Rating, CategorieID) VALUES"
               + "('" + p.articleNumber + "','" + p.name + "','" + p.buyIn + "','" + p.sellPrice + "','" + p.inStock + "','" + p.productDescription + "','"
               + p.systemType + "','" + p.processor + "','" + p.memory + "','" + p.storage + "','" + p.opticalDisk + "','" + p.display + "','" + p.videoCard + "','"
               + p.networkCard + "','" + p.battery + "','" + p.dimension + "','" + p.weight + "','" + p.warranty + "','" + p.actionPrice + "','" + p.rating + "','" + p.categorieID + "')";
            InsertDB(query);
        }

        public ArrayList GetAllProducts()
        {
            string query = "SELECT * FROM product";
            ArrayList arr = GetAllProduct(query);
            return arr;
        }

        public void UpdateProduct(Model.Product p)
        {
            string query = "UPDATE product SET Artikelnummer = '" + p.articleNumber + "', Productnaam =' " + p.name + "', Inkoopprijs ='" + p.buyIn + "',"
                + "Verkoopprijs ='" + p.sellPrice + "', Opvoorraad ='" + p.inStock + "', Productomschrijving ='" + p.productDescription + "',"
                + "Systeemtype ='" + p.systemType + "', Processor ='" + p.processor +"', Geheugen ='" + p.memory + "', Opslag ='" + p.storage + "',"
                + "Optischeschijf ='" + p.opticalDisk + "', Display ='" + p.display + "', Videokaart ='" + p.videoCard + "', Netwerkkaart ='" + p.networkCard + "',"
                + "Batterij ='" + p.battery + "', Afmetingen ='" + p.dimension + "', Gewicht ='" + p.weight + "', Garantie ='" + p.warranty + "', Actieprijs ='" + p.actionPrice +"', Rating ='" + p.rating + "', CategorieID = '" + p.categorieID + "' WHERE Artikelnummer ='" + p.articleNumber + "'"; 
            UpdateDB(query);
        }

        public void DeleteProduct(Model.Product p)
        {
            string query = "DELETE from product WHERE Artikelnummer='" + p.articleNumber + "'";
            DeleteDB(query);

        }




    }
}